$(function(){
	/*-----allcheck-----*/
	$("#all_checked").bind("click",function(){
		if ($(this).attr("checked")=="checked") {
			$("#data_table input:checkbox").attr("checked","checked");
		}else{
			$("#data_table input:checkbox").attr("checked",false);
		}
	})
	/*-----datepicker-----*/
	$( "#datepicker" ).datepicker({
        showOn: "button",
        buttonImage: "/static/img/calendar.png",
        buttonImageOnly: true,
        dateFormat: "yy/mm/dd   D"
    });
     addressInit('cmbProvince', 'cmbCity', 'cmbArea', '江苏', '南京市', '玄武区');
})
function industryTypeSel(obj){
    var styleStr = $(obj).find("option:selected").val();
    if (styleStr) {
        if (styleStr == "其它") {
            $(obj).next().show();
        }else{
            $(obj).next().hide();
        }
    }
}


var receptorType ={
    "1":["人群","地表水","地下水","土壤","大气","海洋"],
    "2":["成人","儿童","成人+儿童"],
    "3":["居民","职业工人"]
}
function receptorTypeSel(obj){
    var styleKey = $(obj).find("option:selected").val();
    if (styleKey) {
        if (styleKey == "1") {
            $(obj).next().next().hide();
        }else{
            $(obj).next().next().show();
        }
        var optionArr = receptorType[styleKey];
        var option = '';
        for (var i = 0; i < optionArr.length; i++) {
            option += '<option>'+optionArr[i]+'</option>';
        }
        $(obj).next().empty().append(option)
    };
}
function metalTypeSel(obj){
    var styleStr = $(obj).find("option:selected").val();
    if (styleStr) {
        if (styleStr == "其他") {
            $(obj).next().show();
        }else{
            $(obj).next().hide();
        }
    }
};
function checkForm(){
    var name = $('form input[name="name"]');
    var metal_type = $('form select[name="metal_type"]');
    var time = $('form input[name="time"]');
    // var cmbProvince = $('form input[name="cmbProvince"]');
    var occupation_standard = $('form select[name="occupation_standard"]');
    var viticm_kind = $('form select[name="viticm_kind"]');
    var viticm_kind_count = $('form input[name="viticm_kind_count"]');
    var accident_description = $('form textarea[name="accident_description"]');
    var pollution_measure = $('form textarea[name="pollution_measure"]');
    var environment_measure = $('form textarea[name="environment_measure"]');
    var crowd_measure = $('form textarea[name="crowd_measure"]');
    var information_measure = $('textarea input[name="information_measure"]');
    var after_measure = $('textarea input[name="after_measure"]');
    var law_measure = $('textarea input[name="law_measure"]');
    var longitude = $('form input[name="longitude"]');
    var latitude = $('form input[name="latitude"]');


    if (name.val()=='') {
        alert("444")
        name.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    alert(metal_type.val())
    if (metal_type.val()=='') {
        metal_type.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    if (time.val()=='') {
        time.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    // if (cmbProvince.val()=='') {
    //     cmbProvince.parents('li').find('span.red').html("*不能为空!");
    //     return false;
    // }
    if (occupation_standard.val()=='') {
        occupation_standard.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    if (viticm_kind.val()=='') {
        viticm_kind.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    if (viticm_kind_count.val()=='') {
        viticm_kind_count.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    if (accident_description.val()=='') {
        accident_description.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    if (pollution_measure.val()=='') {
        pollution_measure.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    if (environment_measure.val()=='') {
        environment_measure.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    if (crowd_measure.val()=='') {
        crowd_measure.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    if (information_measure.val()=='') {
        information_measure.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    if (after_measure.val()=='') {
        after_measure.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    if (law_measure.val()=='') {
        law_measure.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    if (longitude.val()=='') {
        longitude.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    if (latitude.val()=='') {
        latitude.parents('li').find('span.red').html("*不能为空!");
        return false;
    }
    
}